Blogger Information
Blog 20
fans 1
comment 2
visits 16818
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
练习js变量、语句、表达式例子联系一遍 2、函数定义及调用、匿名函数
月迎下弦的博客
Original
805 people have browsed it

练习js变量、语句、表达式例子联系一遍 2、函数定义及调用、匿名函数 


1.语句

JavaScript执行的单位是语句

语句是完成某种特定功能/任务的操作,一般以";"结尾(建议写上,不写也可以)

2.定义语句

语句:
var name ='Mr赵-北京-999999991';
表达式:
var age =19; 
if(age>18){
		alert('您已成年');
} else {
alert('您还未成年');
}



3. 变量的数据类型

  • Number(数字)

  • String(字符串)

  • Boolean(布尔)

  • Symbol(符号)(ES2015 新增)

  • Object(对象)

  •             Function(函数)

  •             Array(数组)

  •             Date(日期)

  •             RegExp(正则表达式)

  • null(空)

  • undefined(未定义)

var age =18;
alert(typeof(age));
var age>8;
alert(typeof(age));
var email = 'Mr赵@php.cn'
alert(typeof(email));
var arr=[1,2,3,[4,5],6];
alert(typeof(arr));
var obj = new Object();
alert(typeof(obj));


4.定义JavaScript函数

function sum(a,b){
    var c =a+b()
    return c;
}
var sum=sum(10,function(){return 20;});
console.log(sum);
function sum1(a) {
  return function(b) {
      return function(c){
        return a+b+c;
      }
  }
}
var x = sum1(1);
var y = x(2);
console.log(y(3));


Correction status:qualified

Teacher's comments:这些都是任何一门语言的基本内容, 一定要掌握
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