You can test your level of knowledge in this area.
At the end of the question is my analysis of the topic with reference to the original blogger’s articles and comments, and everyone is competing to get the answer.
The quiz:
1:
1 && 3
2:
1 && "foo" || 0
3:
1 || "foo" && 0
4:
(1,2,3)
5:
x = {shift:[].shift};
x.shift(); 3: x.length;
6:
{foo:1}[0]
7:
[true, false][ true, false]
8:
'52'.split(' ')[0]
9:
a: b: c: d: e: f: g: 1, 2, 3, 4, 5;
10:
{a: 1, b: 2}[["b"]]
1
"b" 45
12:
{a:{b:2}}
13:
(function(){}())
14:
[1,2,3,4,5][0..toString.length]
15:
({} 'b' > {} 'a')
16:
Number.prototype.x = function(){ return this === 123; };
(123).x() ;
17:
Array(2).join()
18:
vars: var vars = vars;
19:
{ foo = 123 }
20:
x = 1; (function(){return x; var x = 2;}())
2
delete [].length;
22:
RegExp.prototype.toString = function() {return this.source};
/3/-/2/;
23:
{break;4;}
24:
'foo' == new function(){ return String('foo'); };
25:
'foo'.split('') []
Analysis:
1: #1. //3: 1 is true, and the && operation continues to execute the expression on the right, and the result is 3
2: #2. //"foo": logical operator, Same as above, when the operation reaches "foo", the expression has been successful and the expression on the right side of || is no longer executed
3: #3. //1: 1 is converted to bool and is true, and is returned directly, no Then execute
4: #4. //3: Always return the last value
5: #5. //0: When x executes the shift() method, x will have the length attribute. And the returned value is 0
6: #6. //[0] : Two expressions, return the result of the last expression
7: #7. //true : Operate on bool, the result is 1 or 0 is [true,false][1,0], and this formula always takes the last one, [true,false][0]
8: #8. //6: .Operator priority Level greater than operator, '52'.split('')->['5','2']; take [0] to get 5; get 6
9: #9. //5: Ignore the front All :x gets: a:1,2,3,4,5 Result: 5
10: #10. //SyntaxError. Maybe you will be surprised. Isn’t this data in json format? Why does it report an error? I was very surprised at first. In fact, this is not a JavaScript object, but a statement execution of a block-level structure, because there is no assignment statement. When executed as an ordinary statement, {a:1;b:2} is correct. Or a={a:1,b:2}
11: #11. //"b45": Addition of string and number always returns string
12: #12. //2: It's just two statement blocks. It's actually the same situation as question 9 a:b:2, return 2
13: #13. //undefined: The anonymous empty function executes itself, because the return statement is not displayed , automatically returns undefined.
14: #14. //2: This is very interesting. Let’s talk about it in two parts, let’s talk about 0..toString first. If you add "." after an integer, then JavaScript will think it is the point of the floating point number, not the point of the attribute call. If you add a dot after the floating point number, then JavaScript will think it is the point of the attribute call, because JavaScript cannot distinguish this time. What does the user want to do? So 0.. becomes a calling attribute. (This is my guess) At this time, 0. will be converted into an object and its toString function will be called. If you directly use 0.toString, a syntax error will occur. You can test 1.1.toString;.0.toString, etc., they are all callable. Let’s talk about the result of 0..toString.length: 1. Why is it 1? The result returned by calling the length attribute of the function is the number of formal parameters of the function. The default number of formal parameters of the number.toString function in JavaScript is 1. Therefore, the result of [1,2,3,4,5][1] is 2.
15: #15. //true: {} "b" object and string are added -> "[object Object]b", and then logical comparison is performed, "b" > "a". Please do not test {} "b" directly. You will
get NaN. Why? If so, execute the {} statement block first, and then execute "b". The result will naturally be NaN.
16: #16. //false Strict comparison, object on the left, number on the right, type mismatch.
17: #17. //'','': The array is converted into a string after using join, but it is an empty array, so the above result is obtained.
18: #18. //undefined: They are all salted fish, no matter how they turn around, they are still salted fish. They are all undefined, and of course they are still undefined in the end.
19: #19. //123: Block statement execution. She has a little bit to do with her partner, Shenma.
20: #20. //undefined: It is said that every time JavaScript introduces a block scope, it will scan the "var" in the block scope and set the variable value with var life to undefined, regardless of whether it has been done before. Class declaration, including function body.
21: #21. //false: Delete the hair. Can this be deleted? [delete only returns false when a property can not be deleted.]
Reference: http://perfectionkills.com/understanding-delete/ The article makes it very clear that some properties of built-in functions cannot be deleted. , similar to arguments,
length, local variables of functions (function(){ var a = 1; return delete a })(), etc.
22: #22. //1: First modify the toString function on the prototype chain of the regular expression to return the text form of the current regular expression instance object. Then the strings are subtracted. At this time, they will be automatically converted into numbers for calculation.23: #23. // SyntaxError: break statements can only be placed in loops and switch branch statements 24: #24. //false: Borrowing Damian Wielgosik’s very classic explanation (new function(){ return String('foo') ; }).toString() != 'foo'
25: #25. //"f,o,o": After converting the string into an array, add it to the array and then convert it into a string. You can find two Try adding arrays, borrowing Damian Wielgosik’s explanation
Just consider e.g. [1, 2] [3, 4] and see how arrays are casted to string.

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

This tutorial shows you how to integrate a custom Google Search API into your blog or website, offering a more refined search experience than standard WordPress theme search functions. It's surprisingly easy! You'll be able to restrict searches to y

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

This article series was rewritten in mid 2017 with up-to-date information and fresh examples. In this JSON example, we will look at how we can store simple values in a file using JSON format. Using the key-value pair notation, we can store any kind

Enhance Your Code Presentation: 10 Syntax Highlighters for Developers Sharing code snippets on your website or blog is a common practice for developers. Choosing the right syntax highlighter can significantly improve readability and visual appeal. T

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

This article presents a curated selection of over 10 tutorials on JavaScript and jQuery Model-View-Controller (MVC) frameworks, perfect for boosting your web development skills in the new year. These tutorials cover a range of topics, from foundatio

Core points This in JavaScript usually refers to an object that "owns" the method, but it depends on how the function is called. When there is no current object, this refers to the global object. In a web browser, it is represented by window. When calling a function, this maintains the global object; but when calling an object constructor or any of its methods, this refers to an instance of the object. You can change the context of this using methods such as call(), apply(), and bind(). These methods call the function using the given this value and parameters. JavaScript is an excellent programming language. A few years ago, this sentence was


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
