High-quality js ---

How to avoid conflict js

1. anonymous function to wrap the script, can effectively control the global variable, to avoid conflict risk.

--- with hash object as a global variable

was BLOBAL = {};

(function (){

var a=123, b="hellow world";

BLOBAL.str2=a;

BLOBAL.str=b;

}) ();

- can be multi-level namespace

Guess you like

Origin www.cnblogs.com/fdxjava/p/11112380.html