Functions: Arguments aren't typed

by Ken Sprague

HTML

<b><p>Arguments have no defined type.</p>  Open your console to see the output from this code!</b>
<p>This function adds two items, which are passed in as arguments. The parameters inside the function (<code>title</code> and <code>issue</code>) are regular Javascript variables, with no intrinsic <i>type</i>. In this case, we could pass it two strings or two numbers, and it will still do something sensible with them.  </p>
<p>Of course if we passed two arguments that can't be sensibly "added" - say, the window object and a string, we don't know what this function will return. </p>

JavaScript

function addItems(title, issue){
		return title+issue;
}
// you can call this function with any type of arguments!
var sum = addItems(asm, 129);
var fullname = addItems("asm ","129"); 

console.log("sum is "+sum);
console.log("fullname is "+fullname);