JavaScript Knowledge Summary------JS easy to ignore details (continuous update)

Source: Internet
Author: User
Tags delete key

    • In operator
Syntax: boolean "name" in object to determine whether an object has a property
var myObject = {name: ' ng small bits '};console.log (in//true   A return value of TRUE indicates that the name attribute in //False is present in MyObject the   return value is false to indicate that the Name property does not exist in MyObject
    • New operator and direct volume (literal)
var objone = {};   // Direct Volume (literal) generation of objects var New Object ();   // The new operator generates the object
    • Reference types and value types
value type assignment does not change the original data reference type in memory is one, the value change will change the previous data
varNUM1 = ' 13 ';varnum2 =num1;num2= ' 23 '; Console.log (NUM1)//13 Change Value num2 value NUM1 has not changed, proving that NUM1 and num2 in space respectively occupy their own memory, is two independent individualsConsole.log (NUM2)// atConsole.log (NUM1 = = num2);//false Here is a value reference comparison, so only the comparison value is the samevarObj1 = {name: ' Wu Xiao Broken ', age:18};varObj2 =Obj1;obj2.sex= ' Male 'Console.log (OBJ2); //{name: "Wu Xiao", age:18, Sex: "Male"}Console.log (OBJ1);//{name: "Wu Xiao", age:18, Sex: "Male"} when the Obj2 attribute is added, the obj1 changesConsole.log (obj1 = = obj2);//True reference type common one memory, equivalent to Obj2 is obj1 desktop shortcut, obj1 and Obj2 point to the same memory path
    • Delete
  1. To delete an element in an array
  2. Properties or methods of an object
  3. Delete a variable declared with no Var
varARR1 = [1,2,3,4]DeleteArr1[0]console.log (ARR1); //[Empty, 2, 3, 4] length unchanged, just remove the valuevarobj = {name: ' Wu Xiao, age:18 '};Deleteobj.nameconsole.log (obj)//{age:18} Delete key value pairsvarA1 = ' Test ';DeleteA1;console.log (A1);//Test variable A1 still exists, A1 not deletedA2= ' Test ';DeleteA2;console.log (A2)//uncaught REFERENCEERROR:A2 is not defined proves that the variable has been deleted A2
    • Error handling methods
try{ possible error code } catch (e) { e-> received error message }finally{ No matter how it will be last executed }
Try {    //code that may be wrong    //1.Obj.name;//system error Message->obj is not defined    //2.    //throw new error (' I am an error message '); Forcibly throw out an error message}Catch(Error) {//error message thrown if an error is executed Error->tryConsole.log (Error);//referenceerror:a is not defined}finally {    //no matter how it's going to lastConsole.log (' Finally executed me? ‘);//Did I end up doing it? }
    • JS execution: Pre-parse (function, and Var), one sentence to execute
parsing Order: SCIRPT code block, VAR, parsing execution Environment | | function (function precedence above Var)
<script>    console.log (msg); // with the below MSG definition variable exists in two blocks of code therefore: uncaught referenceerror:msgis not defined </script><script>    var msg = ' Wu Xiao Broken ' </script><script>    console.log (msg);    // msg in the last code to complete the quick parse, so print out: Wu Small broken    Console.log (MSG1);  // with MSG1 exists with the same code block, the parsing execution environment exists within a script code block so: undefined    var msg1 = ' Wu Xiao Broken ' </script>

    • An expression
An
expression that has a value in relation to data and operators
.
    • Statement
expression + semi-colon

JavaScript Knowledge Summary------JS easy to ignore details (continuous update)

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.