JavaScript语言实现类似这样的效果: 3.grams.flour

JavaScript语言实现类似这样的效果: 3.grams.flour 参考 Javascript: The Good Parts,第33页代码如下:<html><body><script type="text/javascript">// copied from page 33 of Javascript: The Good PartsFunction.prototype.method = function (name, func){ this.prototype[name] = func; return this;}Number.method(‘chi’, function() { return this*0.333;});document.writeln( (3).chi());document.writeln( "<br>" );document.writeln( (3+1).chi() );document.writeln( "<br>" );document.writeln( 3.2.chi() );document.writeln( "<br>" );document.writeln( 3.0.chi() );// document.writeln( 3.chi() );// SyntaxError: identifier starts immediately after numeric literal</script></body></html>运行结果如下:0.99900000000000011.3321.0656

0.9990000000000001

努力学习,苦中作乐。

,继续期待我的下一个旅行,拿起背包,

JavaScript语言实现类似这样的效果: 3.grams.flour

相关文章:

你感兴趣的文章:

标签云: