Blogger Information
Blog 27
fans 1
comment 0
visits 22619
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JavaScript基础知识-2019年10月21日
思杰的博客
Original
591 people have browsed it

1、把js变量、语句、表达式例子联系一遍
2、函数定义及调用、匿名函数联系一遍
3、作业发到博客上


JavaScript跟php很类似,命名变量的时候,$符号改成var符号,js中变量定义后,后面不再需要在变量前面加上var。

<script>    
// 定义变量        
var a =10;        
var b = 35;        
// 表达式        
var c = a + b;        
alert(c);    
</script>

函数定义跟php也很像

<script>   
function sum(num1,num2){
            var d = num1+num2;
            alert(d);
                    }
sum(1,2);
</script>

匿名函数

<script>
var e = function(){
            return "hello world";        
            }        
alert(e());
</script>


Correction status:qualified

Teacher's comments:php其实是没有变量声明语句的, 直接初始化就用了, js使用var/let/const等关键字来声明变量, 所谓声明变量,可以理解来分配存储空间
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments