JSContext and WKWebView

With WKWebView, how is using JSContext different from UIWebView?

Eg, we want to know when a window open or close occurs in JavaScript or when a console warn or error occurs.