基本Javascript技术
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基本Javascript技术相关的知识,希望对你有一定的参考价值。
These are essential javascript techniques every javascriptr must know. I will be adding more to this list, let me know what you'd like to see. Thanks!
<script type="text/javascript"> //replace a string var astring = "Peter picked a peck of pickled peppers, how many peppers did Peter Piper pick?"; console.log(astring.replace(/peppers/gi,"parsnips")); //truncate a string console.log(astring.substr(0,30)); //display numbers 0 -> 100 skipping 2 for(var i = 0; i<=100; i+=2){ if(i == 0) console.log(0); else console.log(i-1) } </script>
以上是关于基本Javascript技术的主要内容,如果未能解决你的问题,请参考以下文章
精心收集的 48 个 JavaScript 代码片段,仅需 30 秒就可理解!(转载)
VSCode自定义代码片段12——JavaScript的Promise对象