D3.js selection.size() Function
The selection.size() function in D3.js is used to calculate and return the size of the selection. It counts the total element in the selection and returns its size.
Parameters: This function does not accept any parameters.
Return Value: This function returns a Numerical value.
Example 1: When selection is non-empty.
Example 2: When selection is empty.