compacting-names.js

来自「《JavaScript精粹》 源文件下载」· JavaScript 代码 · 共 27 行

JS
27
字号
// Please note: this file contains snippets for comparison
// it is not self-contained or ready-to-use code as such

function castSpell(incantation, potion)
{
  if (typeof potion == 'undefined') { potion = 'felix'; }

  var spell = document.getElementById(incantation);
  if (spell)
  {
    spell.style.display = 'block';
    spell.firstChild.nodeValue = 'Potion: ' + potion;
  }
}

function castSpell(n, p)
{
  if (typeof p == 'undefined') { p = 'felix'; }

  var s = document.getElementById(n);
  if (s)
  {
    s.style.display = 'block';
    s.firstChild.nodeValue = 'Potion: ' + p;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?