JavaScript  realize functional concept