I am using filter method of JavaScript to remove the duplicate entries and I am using the below syntax:
var dataArray = ['g','o','o','g','l','e']
dataArray.filter((value, index) => dataArray.indexOf(value) === index)
The above code works fine and returns me an array by removing the duplicate values. But, when I add a { curly braces after arrow function it returns an empty array.
var dataArray = ['g','o','o','g','l','e']
dataArray.filter((value, index) => { dataArray.indexOf(value) === index })
I am unable to figure out what's the actual difference between both of the syntaxes and why the second one is returning me an empty array.