MOCKSTACKS
EN
Questions And Answers

More Tutorials









Javascript console.count()

console.count([obj]) places a counter on the object's value provided as argument. Each time this method is
invoked, the counter is increased (with the exception of the empty string ''). A label together with a number is displayed in the debugging console according to the following format:


[label]: X

label represents the value of the object passed as argument and X represents the counter's value.

An object's value is always considered, even if variables are provided as arguments:


var o1 = 1, o2 = '2', o3 = "";
console.count(o1);
console.count(o2);
console.count(o3);
console.count(1);
console.count('2');
console.count('');

Output

1: 1
2: 1
: 1
1: 2
2: 2
: 1

Strings with numbers are converted to Number objects:


console.count(42.3);
console.count(Number('42.3'));
console.count('42.3');

Output

42.3: 1
42.3: 2
42.3: 3

Functions point always to the global Function object:


console.count(console.constructor);
console.count(function(){});
console.count(Object);
var fn1 = function myfn(){};
console.count(fn1);
console.count(Number);

Output

[object Function]: 1
[object Function]: 2
[object Function]: 3
[object Function]: 4
[object Function]: 5


Conclusion

In this page (written and validated by ) you learned about Javascript console.count() . What's Next? If you are interested in completing Javascript tutorial, your next topic will be learning about: Javascript console.clear.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.