Home > Web Front-end > JS Tutorial > The parsing and execution order of javascript is different in various browsers_javascript skills

The parsing and execution order of javascript is different in various browsers_javascript skills

WBOY
Release: 2016-05-16 16:55:24
Original
1348 people have browsed it

Introduction

Javascript is an interpreted language and its execution is top-down. However, each browser has a slightly different understanding of "top-down", and the upstream and downstream of the code, that is, the program flow, are crucial for the correct operation of the program. So we need to deeply understand the execution order of js. To this end, I designed the following eight experiments to obtain the most accurate results.

Experiment

Copy code The code is as follows:



Postscript

When defining a JavaScript function, the function name is the identifier of the function object, and the number of parameters is just an attribute of the function. It is not possible to implement overloading by defining functions with different numbers of parameters.
When calling a function, js finds the corresponding function object through the function name, and then matches the expression parameter list in order according to the parameters when the function is defined. The excess parameters are discarded, and the insufficient parameters are treated as undefined, and then the function is executed. code.

So when defining a function, the required parameters are usually placed at the beginning of the parameter list, and the optional parameters are placed after the required parameters.

Notes

1. The results of the above eight experiments are obtained through 360 browser (version/kernel: 6.3.1.142/21.0.1180.89) and Firefox browser (version: 27.0.1 ) is obtained by running.
2. The above eight experiments are independent of each other. Please run them separately to get correct results.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template