" Join operator +"
<script>Console.log (1+2+ ' a ' +3+4);</script>
Output:
3a34
The logical operator returns the first value that can determine the result of an expression
Example ①
<script>varfalse; var b = Ten; var true ; var d = A | | B | | C;console.log (d); Console.log (typeof(d)); </script>
Output:
10
Number
Example ②
<script>var a = True; var B = False; var C = a && b;console.log (c); Console.log (typeof(c)); < ;/script>
Output:
False
Boolean
Example ③ (&& priority above | | )
<script>vartrue; var b = Ten; var false ; var d = A | | b && C;console.log (d); Console.log (typeof(d)); </script>
Output:
True
Boolean
Often used in some frameworks | | To do browser compatibility, form: WINDOW.A = WINDOW.A | | window.b
" iterating over an array "
<script>var arr = [' Hello ', ' world ',]; for (var i=0; i<arr.length; i++) { console.log (arr[i]);} </script>
Output:
Hello
World
2015
" Traverse Object "
<script>var obj = {A: ' Hello ', B: ' World ', c:2015}; for (var in obj) { Console.log (key+ ":" +Obj[key]);} </script>
Output:
A:hello
B:world
c:2015
" Object Actions "
When calling properties with native types such as numbers, strings, JS will instantly wrap these native types into objects
Example ①
<script>var str = "HelloWorld"; Console.log (str.length); </script>
Output 10
Example ②
<script>var str = "HelloWorld"; Console.log (str.substr (2,3)); </script>
Output: Llo
Example ③
<script>var arr = [' Arsenal ', ' Chelsea ', ' Manchester City ', ' Liverpool '];console.log (arr.join (')')var str = "Php,java,python"; Console.log (Str.split (', ')); </script>
Output:
Arsenal, Chelsea, Manchester City, Liverpool
["PHP", "Java", "Python"]
JavaScript notes and summaries (2-3) JavaScript operators, control structures, and object operations