1

In Swift, we can use Special literals to get fileName, methodName, lineNumber etc dynamically.

enter image description here

Is there similar functionality available in javascript to get fileName / methodName / lineNumber etc dynamically ?

theapache64
  • 10,926
  • 9
  • 65
  • 108
  • In what environment? You [can do so in NodeJS](https://stackoverflow.com/questions/14201475/node-js-getting-current-filename), but for security reasons I don't believe the browser affords any such nicety. – Alexander Nied Jun 15 '18 at 14:54
  • Is it possible in `react-native` environement ? @AlexanderNied – theapache64 Jun 15 '18 at 14:55

1 Answers1

2

Short answer:

no

You can get the name of a function in es6 with function.name: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name but that's about it.

You could return these values from native code to js, but that would tell you about the swift file, not the js file.

Jake Johnson
  • 1,856
  • 1
  • 17
  • 26