Things which you might have not known about the “forEach” loop

1. `return` statement Doesn’t stop the loop

if you think the below code only prints “1,2,3” you are wrong

the reason for this behaviour is that we are passing a callback function in our “foreach” function, which behaves like a normal function and is appliead to each element no matter if we “return” from one.

2. `break` statement Don’t work

do you think “foreach” loop break when equals to 3 ?

The above code will throw an exception

This is because , technically the break not inside a loop.

3.`Continue` statement would not work as well

Do you think this code…


Cross domain communication b/w Vue component and iframe.

Cross domain communication (also called Cross-origin) can be difficult and security risks. “window.postmessage()” method gives a provision for sending cross-domain e.g.: between a page and iframe or pop-up.

Required methods and their syntax

  1. window.postMessage() — to send the message to window
  2. window.addEventListener(“message”, targetOrigin, [transfer]) — to receive and process the message

Example

If you are using vuejs for iframe and target window both.

  1. Lets pick a iframe first from where you want to transfer object or any message to target window
iframe.vue

In this component where we going to send message to parent window. here we have…

Nitish Thakur

Senior Software Engg. @customersuccessbox

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store