3-28 Default values || operator will return first one could be coerced to true or false js default value 小技巧12345678910111213function greet(name){ console.log('Hello ' + name);}greet(); // 'Hello undefined'function greet2(name){ name = name || '<Your name here>' console.log('Hello ' + name);}greet2(); // 'Hello <Your name here>' 3-29 Framework aside: Default valuelib1.js12var libname = 'lib1'; lib2.js12345var libname = 'lib2';// batter way// window.libname = window.libname || 'lib2'; app.js123console.log(libname);//lib2 index.html123456789101112<!DOCTYPE html><html><head> <title></title></head><body> <script src = lib1.js type="text/javascript"></script> <script src = lib2.js type="text/javascript"></script> <script src = app.js type="text/javascript"></script></body></html>