Home  >  Article  >  Web Front-end  >  What are Ruby and JavaScript? What is the difference between Ruby and JavaScript

What are Ruby and JavaScript? What is the difference between Ruby and JavaScript

云罗郡主
云罗郡主Original
2019-01-25 17:20:296198browse

What are Ruby and JavaScript? When many novices are learning Ruby and JavaScript, some things can only be done with JavaScript and not with Ruby. So what is the difference between Ruby and JavaScript? Below, php Chinese website will summarize the differences between Ruby and JavaScript. [Recommended reading: JavaScript Video Tutorial]

What are Ruby and JavaScript? What is the difference between Ruby and JavaScript

1: What is Ruby and JavaScript

1. What is Ruby

Ruby is a programming language that is often used to handle frequently viewed Web services. It mainly has member registration functions, login and publishing functions, and email sending functions when registering on a certain website. When becoming a member, many people have seen temporary registration and sending some emails such as "Thank you", but this process is processed using programs.

2. What is JavaScript?

JavaScript is one of the programming languages ​​​​such as Ruby, used to display the appearance and effect of a Web site. JavaScript is an essential technology. The role of JavaScript is to create actions in a visible form.

2: What is the difference between Ruby and JavaScript

The biggest difference is whether it is run on the client side or the server side. If you want to run the program on the client (browser), You just need to use JavaScript, if you want to run a program on a Ruby server, you have to write it in Ruby, in short, what you have to do is decide on the programming language. For example, if you want to move an image in the browser, you can only use JavaScript.

But there is no difference in what the language specifications of the two languages ​​can do. However, the environment in which it can be executed is different, and if you are familiar with one programming language, it is easy to transfer that knowledge to the other language .

Three: Using JavaScript on Ruby on Rails

Using Ruby on Rails (Ruby Framework) and JavaScript implementation, we can use the Rails command to create a file called "javascriptsample " file, and use JavaScript to explain the mobile process. On the terminal, enter the following command:

rails new javascriptsample
cd javascriptsample
rails g controller static_pages index

Write the following code into the file named "index.html.erb"

<button id =“button 1”onclick =“effect()”>使按钮变为红色</ button>
<script type =“text / javascript”>
function effect(){
  var button 1 = document.getElementById(“button 1”)
  button1.style.backgroundColor =“red”;
}
</ script>

Effect As follows:

What are Ruby and JavaScript? What is the difference between Ruby and JavaScript

The above is a complete introduction to what are Ruby and JavaScript? What are the differences between Ruby and JavaScript? If you want to know more about js, please pay attention to PHP Chinese net.


The above is the detailed content of What are Ruby and JavaScript? What is the difference between Ruby and JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn