JavaScript. Properties and functions

Home » Tutorials » JavaScript » JavaScript. Properties and functions
In this tutorial we will discuss functions and properties. While writing code you often need to do a lot of repetitive operations. This operations are better to write into special blocks – functions.
Function is subprogramm which works with any data and returns any result. Function often needs some secondary data – parameters. Besides, function has got a name (it is recommended, functions name tell developers, what it does) and function body – code. For example:

Code lesson (js)

function function_name (argument) {
	// body...
All languages has got its own functions. But always developers need to write their custom functions, because language functions can’t satisfy developer with him tasks.

Code lesson (js)

var str = "Я люблю javaScript";


var symb = str.charAt(0);


str = str.toUpperCase();

function summa(a,b) {
	var s = a + b;
	return s;		

var res = summa(5,10);

function division(a,b) {
	if(b == 0) {
		alert("На нуль делить нельзя");
		return false;
	var d = a/b;
	return d;

var div = division(10,5);


Submit a Comment

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This