This is not a javascript: What?

javascript protocol.
<a href="javascript:void(0);"> xxx </a>
event-based event, for example: <input onblur = "check ( );" /> not required, since the event need not be specified by the protocol. You can type javascript: document. GetElementByID ( "XXXX"). Value of the address bar = false; This code is modified by adding the page to indicate agreement javascript.
Question
this is not javascript: What?
For example, I've seen f: check ()
How to explain such a function?
Questioning and answer
that is true:
Javascript weak type, object-oriented.
I want to give you a few examples. Please read them out.
1. var sitename = baidu; // define variable
2. var showmsg = function (text) Alert (text); // defined functions, the function corresponding to showmsg (A) alert (A) ;
except that it can be referenced.
three. var users = [ 'zhangsan', 'lisi', 'wangwu']; // define an array.
4. var user = name: 'shangsan' , sex: 'boy', age: 22 // define an object, where the object can access the key user. Of / boy

However, we know that an object individual has the property is not perfect, so we define a number of methods for it, such as:
var Me = name: 'nqlijiangtao', 'Age': 22 is, sayHello:. Function () Alert (the this name );
in this case, Me object has a sayHello () method which does not require new methods. such as me. say hello();

Above f: check () alert (); f is a property of an object as a method of adding after obj.f () is performed. These are two concepts, the former running to declare the agreement in href.

You can write an example.

var check = function () alert ( " check function has been called ..."); // will not perform a
check (); // execution

About javascript there are some very strange things interesting. As a front-end development, I really love the language.

(Function (obj) obj.showmsg (); ( showmsg: function () alert ( "are you ...");));
in fact, the above problems are not the same:
First look at the second parentheses, showmsg: function ( ) alert ( "are you ..." ); this is an object, the object has no name, there is a function showmsg (); in front of the parentheses define a function, not the name of the function, the function passed in the implementation of the method is showmsg parameter object . The two have different meanings in parentheses. The former is responsible for declaring a function body, which executes and pass parameters.

Guess you like

Origin www.cnblogs.com/blogst/p/10950068.html