额外区块类型 (EBT) - 全新的布局构建器体验❗
GLightbox is a pure javascript lightbox (Colorbox alternative without jQuery)❗
It can display images, iframes, inline content and videos with optional autoplay for YouTube, Vimeo and even self-hosted videos.
滚动
10/10/2025, by Ivan
在本课中,我们将学习 JavaScript 中的函数——如何编写函数以及函数的类型。你也可以阅读以下 PHP 课程中的相关章节,所有示例在 JavaScript 中同样适用:
JavaScript 的语法与 PHP 基本相同,但有一个重要区别:在 JavaScript 中,所有变量默认都是全局变量。如果变量在函数调用之前已经声明,它将在所有嵌套函数中生效。因此,以下代码在 PHP 和 JavaScript 中的执行结果会不同。
PHP:
<?php
function inc(){
$x++;
return $x;
}
$x = 10;
inc($x);
print $x;
?>
JavaScript:
<script>
function inc(){
x++;
return x;
}
x = 10;
inc(x);
alert(x);
</script>