JavaScript from jQuery

  1. http://learn.jquery.com/javascript-101/types/
    1. primitives
      1. String: “”,‘’,\
      2. Number: integer and floating point
      3. Boolean:true or false
      4. Null:null
      5. Undefined:undefined
    2. objects
      1. Object:object literal {:,:},unordered key and value pairs,key is formally known as a property and the value can be any valid JavaScript type, even another object. To create or access a property on an object, we use what is known as "dot notation" or "bracket notation."
      2. Array:ordered by the index of each item it contains.The index starts at zero and extends to however many items have been added, which is a property of the array known as the .length. Similar to a basic object, an array can be created with the Array constructor or the shorthand syntax known as array literal [].
      3. Function
    3. Type Checking with jQuery
      1. ===
      2. typeof
      3. jQuery.isFunction( myValue ); // false
        jQuery.isPlainObject( myValue ); // false
        jQuery.isArray( myValue ); // true
  2. http://learn.jquery.com/javascript-101/operators/
    1. Operations on Numbers & Strings
    2. Logical Operators
    3. Comparison Operators
  3. http://learn.jquery.com/javascript-101/conditional-code/
    1. Falsy Things:
      // Values that evaluate to false:
      false
      "" // An empty string.
      NaN // JavaScript's "not-a-number" variable.
      null
      undefined // Be careful -- undefined can be redefined!
      0 // The number zero.
    2. Truthy:
       // Everything else evaluates to true, some examples:
      "0"
      "any string"
      [] // An empty array.
      {} // An empty object.
      1 // Any non-zero number.
    3. Conditional Variable Assignment with the Ternary Operator
    4. Switch Statements
  4. http://learn.jquery.com/javascript-101/loops/
    1. for ( [initialization]; [conditional]; [iteration] ) {
       
      [loopBody]
       
      }
    2. while ( [conditional] ) {
       
      [loopBody]
       
      }
    3. do {
       
      [loopBody]
       
      } while ( [conditional] )
    4. Breaking and Continuing
  5. http://learn.jquery.com/javascript-101/reserved-words/
    1. break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import in instanceof interface let new null package private protected public return static super switch this throw true try typeof var void while with yield
  6. http://learn.jquery.com/javascript-101/arrays/
    1. Arrays are zero-indexed(从0开始索引), ordered lists(保留原始的入栈顺序) of values. 
    2. .sort(): 排序之后原来的数组已被改变,Sorts an array. It takes one parameter, which is a comparing function. If this function is not given, the array is sorted ascending.The return value of descending (for this example) is important. If the return value is less than zero, the index of a is before b, and if it is greater than zero it's vice-versa. If the return value is zero, the elements' index is equal.
    3. .forEach(): The function takes up to three arguments:
      1. Element – The element itself.
      2. Index – The index of this element in the array.
      3. Array – The array itself. All of these are optional
    4. .unshift(): Inserts an element at the first position of the array
    5. .shift() Removes the first element of an array.
    6. splice():部分元素替换, Removes a certain amount of elements and adds new ones at the given index. It takes at least three parameters: 1 myArray.splice( index, length, values, ... ); Index – The starting index. Length – The number of elements to remove. Values – The values to be inserted at the index position.
    7. .slice():提取从index开始到最后的部分, Extracts a part of the array and returns that part in a new array. This method takes one parameter, which is the starting index:
    8. reverse():倒序之后原来的数组已被改变, the elements of the array are in reverse order after calling this method
    9. .push(): is a function that adds an element on the end of the array and expands the array respectively.
    10. .pop() : removes the last element of an array. It is the opposite method of .push()
    11. .join() creates a string representation of an array by joining all of its elements using a separator string
    12. Concatenate two or more arrays with .concat():
    13. .length property is used to determine the amount of items in an array
  7. http://learn.jquery.com/javascript-101/objects/
    1. Objects contain one or more key-value pairs. The key portion can be any string. The value portion can be any type of value: a number, a string, an array, a function, or even another object. When one of these values is a function, it’s called a method of the object. Otherwise, they are called properties.
  8. http://learn.jquery.com/javascript-101/functions/
    1. // Function declaration.
      function foo() {
      // Do something.
      }
    2. // Named function expression.
      var foo = function() {
      // Do something.
      };
    3. // A simple function.
    4. // A function that returns a value.
    5. // A function that returns another function.
    6. Immediately-Invoked Function Expression (IIFE):
      (function() {
      var foo = "Hello world";
      })();
    7. Functions as Arguments
  9. http://learn.jquery.com/javascript-101/testing-type/
    1. var myRegExp = /(\w+)\s(\w+)/;
    2. if ( Object.prototype.toString.call( myArray ) === "[object Array]" ) {
      // Definitely an array!
      // This is widely considered as the most robust way
      // to determine if a specific value is an Array.
      }
  10. http://learn.jquery.com/javascript-101/this-keyword/
    1. this is a special keyword that is used in methods to refer to the object on which a method is being invoked
      • If the function is invoked using Function.call() or Function.apply()this will be set to the first argument passed to .call()/.apply(). If the first argument passed to .call()/.apply() is null or undefinedthis will refer to the global object (which is the window object in web browsers).
      • If the function being invoked was created using Function.bind()this will be the first argument that was passed to .bind() at the time the function was created.
      • If the function is being invoked as a method of an object, this will refer to that object.
      • Otherwise, the function is being invoked as a standalone function not attached to any object, and this will refer to the global object.
  11. http://learn.jquery.com/javascript-101/scope/
    1.  In a browser, the global scope is the window object
  12. http://learn.jquery.com/javascript-101/closures/
    1. Closures are an extension of the concept of scope
    2. for(var i=0;i<5;i++){console.log(i+" : before");setTimeout(function(){console.log(i + " "+new Date());},i*1000);console.log(i+" : after")}

posted on 2014-12-07 12:55  架构师师  阅读(245)  评论(0编辑  收藏  举报

导航