Tuesday, March 18, 2014

How to find the length of the object using javascript

<!DOCTYPE html>
<html>
<body>

<table>
    <tbody id="tbody"></tbody>
</table>

<script>
var obj = {    "key": "apple",    "value": 1.90};  
var a= Object.keys(obj).length;
document.write(a);

</script>

</body>
</html>

 output: 2

No comments:

Post a Comment