Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Javascript урок 4 Функции

16/04/2025, by Ivan

In this lesson, we will look at functions in JavaScript—how to write them and what kinds of functions exist. You can read about functions in these PHP lessons; all the examples will also work in JavaScript:

PHP Lessons – Lesson 7 – PHP Functions and Functional Programming

PHP Lessons – Lesson 9 – Recursion

The syntax is the same as in PHP, but there's one difference. In JavaScript, all variables are global by default, and they work in all nested functions if declared before the function is called. For example, the following code behaves differently in PHP and 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>