JS Basics Review

Source: Internet
Author: User
Tags logical operators

 JS basic Syntax Netcape JS Basic Syntax Specification (ecmascript1,2,3,3.1,5 (IE9), 6 ES es6=es2015) DOM BOM BOM: is implemented by the browser vendor, so the differences are compared Large DOM: The relevant specification is maintained by the Internet Explorer node's advantages without browser compatibility issues front-end projects try not to use ES6, you need to consider compatibility issues--------------------------------data Types-------- -------------------1. Data type classification:Base data type: Number string Boolean undefinedNULLComplex data types: objects (arrays, functions, dates)
 undefined: Data not defined in a state 2.typeof the returned data type can return these six data types: number  string  boolean  function   Undefined  object date, array, regular is an object type can use typeof to detect the data type in the first 5 ' notice that the string is returned   lowercase console.log (typeof  alert ()) ;//function   Use the typeof detection function to return the function 3. logical operators &&  :   True on the left, return to the right, false on left, return to left       (if the left is true, you need to calculate the right side so it will return to the right result) | | &NBSP: The left is true, return to the left, false on the left   return to the right   (if the left is true, there is no need to calculate the right side, so it will directly return to the left) console.log (undefined  &&  10);//undefinedconsole.log (0 | | 3);//3    False value: False value:   empty string ""   value 0   false     NULL ( The declared variable is assigned a value but the assignment is a null value)   Undefined (the variable is declared but not defined)    nan (not a number, NaN itself is of type #)   4. Gets the property undefined by the object, returns the undefined not the  is not definedvar  obj = {name: ' xiaoming '};console.log (obj.age);// Undefined5. Value type   Reference type value type: Numeric string  boolean  null  undefined Reference type: Object  5.  instanceofvar  result = obj  instanceof   XXX; The return value is a Boolean type detection OBWhether J is an instance of the XXX class
  1. var obj ={};
  2. console.log(obj instanceof Object);
  3. var arr =[1,2,3,4];
  4. console.log(arr instanceof Array);
Constructor property: holds a reference to a function that constructs a particular object instance
  1. console.log(arr.constructor==Array);//true
  2. console.log(obj.constructor==Object);//true
  3. console.log(num.constructor==Number);//true
Code debugging exception capturing object-oriented basics review constructors and prototype variable declaration promotion (Lexical scope primitive Introduction) Scope: global scope local scope (write a function to produce a local scope)
  1. function bar(){
  2. function foo(){}
  3. foo =10;//2.给变量foo赋值 10 foo变为了一个number类型
  4. // function foo() {}//1.函数声明 提升到当前作用域的顶端
  5. return foo;//3.将number类型的的foo返回
  6. }
  7. // console.log(foo);
  8. console.log(typeof bar());
  1. function fun(a, b){
  2. for(var i =0; i < arguments.length; i++){
  3. console.log(arguments[i]);//分别打印的函数的参数
  4. }
  5. return a + b;
  6. }
  7. console.log(fun(3));//NaN 3+undefined 得到是一个NaN
  1. var foo =function bar(name){
  2. console.log("hello"+ name);
  3. };
  4. foo("world");
  5. //bar();//无法打印 bar is not defined
  6. /*在函数内部,bar可以被访问,此时的bar就相当于foo,相当于函数本身*/
  7. //只能通过打印foo.toString()从而找到bar
  8. console.log(foo()== bar());
  9. console.log(foo.toString());//打印的是function bar(name) 函数体



From for notes (Wiz)



JS Basics Review

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.